<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

/**
 * 商店浏览量模型
 * author : lizhenhua
 * date : 2017-11-6
 */
class ShopDetails extends Model
{

    protected $table = 'shop_details';

    public $timestamps = false;

    protected $fillable = [
        'id',
        'shop_id',
        'user_id',
        'view',
        'date'
    ];

    /**
     * 计算某个日期区间的商铺浏览量
     * @param  [type] $shop_id  [description]
     * @param  [type] $bg_time  [description]
     * @param  [type] $end_time [description]
     * @return [type]           [description]
     */
    public static function getCountByDate($shop_id, $bg_time, $end_time)
    {
        $count = ShopDetails::where('shop_id', $shop_id)->whereBetween('time', [$bg_time, $end_time])->count();

        return $count;
    }
}
